<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui-date,auto-complete,dtvalidate,layui,chosen'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
        .has-no{color:#3366cc;}
        .has-success{color: #1ab394;}
        .has-warning{color: #f8ac59;}
        .has-error{color: #ed5565;}
        .has-receive{color: #9E792E;}
        .remark {
            width: 100%; /*自动适应父布局宽度*/
            overflow: auto;
            word-break: break-all;
        }
    </style>
    <%}%>
</head>

<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                <button  class="import-btn layui-btn layui-btn-sm import-btn" style="margin-left: -2px" id="import-btn" name="import-btn">
                    <i class="layui-icon"></i>导入处理数据
                </button>

                <button  class="export-btn layui-btn  layui-btn-sm btn-info"  style="">
                    <i class="fa fa-check-square-o" aria-hidden="true"></i> 导出待处理数据
                </button>
            </div>
            <!-- START 数据表格 -->
            <table id="portTable"
                   data-toolbar="#toolbar"
                   data-side-pagination="server"
                   data-pagination="true"
                   data-resizable="true"
                   data-url="/sea/finance/vt/findByDealSku.do"
                   data-page-size="15"
                   class="table table-striped table-hover"
            >
            </table>
        </div>
    </div>
    <!-- END 数据表格 -->
</div>



<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer,chosen,chosen-demo,layui,upload'}){}%>
<script>
    var ind=null;

    layui.use('upload', function(){
        var upload = layui.upload;
        upload.render({
            elem: '#import-btn', //绑定元素,
            accept:'file',
            url: '/sea/finance/vt/importDealSku/', //上传接口
            data:{},
            before:function () {
                layer.msg("数据导入中,请稍后查询导入结果！", {
                    icon: 0, btn: ['确定'], time: 0, shade: [0.8, '#393D49'], yes: function (index, layero) { // 默认的是 按钮一
                        layer.closeAll();
                        $portTable.bootstrapTable('refresh');
                    }
                });
            },done: function(data){

            }
            ,error: function(){
                //请求异常回调
                layer.closeAll();
            }
        });
    });


    laydate.render({
        elem: '#period',
        type: 'month'
        ,trigger: 'click'
    });

    $('.save-btn').on('click',function(){
        layer.closeAll();
        layer.load();
        importExcel();
    });

    function importExcel() {
        $.ajax({
            url: "/sea/finance/vt/importDetail/",
            data:  new FormData($('#info-form')[0]),
            type: "post",
            // async: false,
            processData: false,//用于对data参数进行序列化处理 这里必须false
            contentType: false, //必须
            beforeSend:function () {
                            layer.msg("数据导入中,请稍后查询导入结果！", {
                                icon: 0, btn: ['确定'], time: 0, shade: [0.8, '#393D49'], yes: function (index, layero) { // 默认的是 按钮一
                                    layer.closeAll();
                                    $portTable.bootstrapTable('refresh');
                                }
                            });
            },
            success: function (data) {
                if(data.ok){
                    layer.closeAll();
                    layer.msg("上传成功！",{icon: 0,time:1500,shade: [0.8, '#393D49']});
                    $portTable.bootstrapTable('refresh');
                }else{
                    layer.closeAll(); //关闭弹窗
                    layer.msg(data.msg,{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){
                            layer.closeAll();
                        }});
                }
            },
            error:function (data) {
                layer.msg("接口异常!请联系管理员!",{icon: 0,btn: ['确定'],time:0,shade: [0.8, '#393D49'],yes: function(index, layero){
                        layer.closeAll();
                    }});
            }
        });
    }

    $('.import-v2-btn').on('click',function () {
        layer.open({
            type:1,
            title:'生成采购单',
            area:['650px','400px'],
            skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
            shadeClose:false,
            resize: false,
            scrollbar: false,
            maxmin: false,//出现最大化按钮
            content:$('#layer_supplier_window')
        })
    });

    var $portTable = $('#portTable');
    $(function(){
        //START 表格配置
        $portTable.bootstrapTable({
            columns: [
                {
                    title: '期间',
                    field: 'period',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '主体',
                    field: 'shop_name',
                    align: 'center',
                    valign: 'middle'
                }
                ,
                {
                    title: '店铺',
                    field: 'brand_name',
                    align: 'center',
                    valign: 'middle'
                }
                ,
                {
                    title: '国家',
                    field: 'country_name',
                    align: 'center',
                    valign: 'middle'
                }
                ,
                {
                    title: '源文件',
                    field: 'file_name',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'transaction_type',
                    field: 'transaction_type',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'order_id',
                    field: 'order_id',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '发生金额',
                    field: 'amount',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'feeName',
                    field: 'fee_name',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'feeType',
                    field: 'fee_type',
                    align: 'center',
                    valign: 'middle'
                }
            ],
            onLoadSuccess : function(){

            }
        });
        //操作菜单
    });





    $('.export-btn').on('click',function(){

        layer.confirm('是否要导出待处理数据？', {
            btn: ['确定','取消'],title:'提示'
        }, function(){
            layer.closeAll();
            layer.load();
            window.location.href='/sea/finance/vt/exportDealSku.do';
            layer.closeAll();
        });
    });
</script>
</body>
</html>
